<template>
<view class="snowy-form">
		<uni-forms ref="formRef" :model="formData" label-position="top" labelWidth="auto">
			<uni-forms-item label="意见建议类型:" name="adviceType" required :rules="[{ required: true, errorMessage: '建言类别' }]">
				<uni-data-checkbox v-model="formData.adviceType" :localdata="adviceTypeOptions" />
			</uni-forms-item>
			<uni-forms-item label="意见建议内容：" name="adviceContent" required :rules="[{ required: true, errorMessage: '请输入意见建议内容' }]">
				<textarea v-model="formData.adviceContent" placeholder="中文标识"></textarea>
			</uni-forms-item>
		</uni-forms>
		<tui-button margin="50rpx 0" :preventClick="true" :shadow="true" @click="submit">提交</tui-button>
	</view>
</template>


<script lang="ts" setup>
	import { nextTick, reactive, ref, computed } from "vue"
	import store from '@/store'
	import { onLoad, onShow, onReady, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"
	// 性别
	const adviceTypeOptions = uni.$snowy.tool.dictList('意见建议分类')
	
	import bizAdviceApi from "@/api/biz/biz-advice-api";
	const formRef = ref()
	const formData = ref({})
	const isEdit = ref(false)
	const allEnv = computed(() => {
		return store.getters.allEnv
	})
	// 加載
	onLoad((option) => {
		if (!option.key) {
			return
		}
		formData.value = {
			key: option.key,
			...allEnv.value[option.key]
		}
		isEdit.value = true
	})
	const submit = () => {
		uni.$snowy.modal.confirm(`确认提交`).then(() => {
			formRef.value.validate().then(res => {
				bizAdviceApi.submitForm(formData.value).then(data => {
					uni.$snowy.modal.alert("提交成功")
				})
			})
		})
	
	}
</script>
<style lang="scss">
	.title{
		
	}
	
</style>

